//
//  DSectionController.m
//  BaseProject
//
//  Created by itzhaolei on 2024/5/13.
//

#import "DSectionController.h"
#import "OperationCollectionViewCell.h"
#import "PageListCoordinator.h"

@implementation DSectionController

#pragma mark - Overwrite

// 当前区域内的单元格所占大小
- (CGSize)sizeForItemAtIndex:(NSInteger)index {
    return CGSizeMake(UIScreen.mainScreen.bounds.size.width, UIScreen.mainScreen.bounds.size.width);
}

// 当前区域内的单元格构建与复用
- (__kindof UICollectionViewCell *)cellForItemAtIndex:(NSInteger)index {
    OperationCollectionViewCell *cell = [self.collectionContext dequeueReusableCellOfClass:[OperationCollectionViewCell class] forSectionController:self atIndex:index];
    cell.contentView.backgroundColor = UIColor.lightGrayColor;
    
    MJWeakSelf;
    // 刷新指定单元格
    [[[cell.reloadC1Button rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:cell.rac_prepareForReuseSignal] subscribeNext:^(__kindof UIControl * _Nullable x) {
        [((PageListCoordinator *)weakSelf.delegate).reloadBSectionSubject sendNext:nil];
    }];
    // 刷新所有单元格
    [[[cell.reloadAllButton rac_signalForControlEvents:UIControlEventTouchUpInside] takeUntil:cell.rac_prepareForReuseSignal] subscribeNext:^(__kindof UIControl * _Nullable x) {
        [((PageListCoordinator *)weakSelf.delegate).reloadAllSubject sendNext:nil];
    }];
    
    return cell;
}

@end
